package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.ProductUnit;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProductUnitDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主id")
    private Integer id;

    @ApiModelProperty(value = "计量名称")
    private String name;

    @ApiModelProperty(value = "公司id")
    private Integer companyId;

    @ApiModelProperty(value = "是否启用：0禁用，1启用")
    private Integer state;


    public ProductUnitDTO() {}

    public ProductUnitDTO(ProductUnit entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static ProductUnitDTO convert(ProductUnit entity) {
        return new ProductUnitDTO(entity);
    }

    public static List<ProductUnitDTO> convertList(List<ProductUnit> list) {
        List<ProductUnitDTO> resultList = new ArrayList<>();
        for (ProductUnit entity : list) {
            resultList.add(new ProductUnitDTO(entity));
        }
        return resultList;
    }}
